package cn.iocoder.an.module.mold.controller.admin.upkeeptobe.vo;

import cn.iocoder.an.module.mold.dal.dataobject.account.AccountDO;
import cn.iocoder.an.module.mold.dal.dataobject.drawingno.DrawingNoDO;
import cn.iocoder.an.module.mold.dal.dataobject.upkeepcategory.UpkeepCategoryDO;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fhs.core.trans.anno.Trans;
import com.fhs.core.trans.constant.TransType;
import com.fhs.core.trans.vo.VO;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;

import java.util.*;

import org.springframework.format.annotation.DateTimeFormat;

import java.time.LocalDateTime;

import cn.idev.excel.annotation.*;
import cn.iocoder.an.framework.excel.core.annotations.DictFormat;
import cn.iocoder.an.framework.excel.core.convert.DictConvert;

import static cn.iocoder.an.framework.common.util.date.DateUtils.TIME_ZONE_DEFAULT;

@Schema(description = "管理后台 - 待保养模具 Response VO")
@Data
@ExcelIgnoreUnannotated
public class UpkeepTobeRespVO implements VO {

    @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "14947")
    @ExcelProperty("主键")
    private Long id;

    @Schema(description = "图号id", requiredMode = Schema.RequiredMode.REQUIRED, example = "15140")
    @Trans(type = TransType.SIMPLE, target = DrawingNoDO.class, fields = "drawingNo", ref = "drawingNo")
    private Long drawingNoId;

    @Schema(description = "图号")
    @ExcelProperty("图号")
    private String drawingNo;

    @Schema(description = "模具台账id")
    @Trans(type = TransType.SIMPLE, target = AccountDO.class, fields = {"name", "code", "totalUsageCount", "usedCount"}, refs = {"name", "code", "totalUsageCount", "usedCount"})
    private Long accountId;

    @Schema(description = "模具名", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四")
    @ExcelProperty("模具名")
    private String name;

    @Schema(description = "编码", requiredMode = Schema.RequiredMode.REQUIRED)
    @ExcelProperty("编码")
    private String code;


    @Schema(description = "保养类型id", example = "25044")
    @Trans(type = TransType.SIMPLE, target = UpkeepCategoryDO.class, fields = {"name", "accountMethod", "upkeepPeriod"}, refs = {"upkeepCategory", "accountMethod", "upkeepPeriod"})
    private Long upkeepId;

    //保养分类
    @Schema(description = "保养分类", example = "工装保养")
    @ExcelProperty("保养分类")
    private String upkeepCategory;

    //核算方式
    @Schema(description = "核算方式", example = "核算方式")
    @ExcelProperty("核算方式")
    private Integer accountMethod;

    //核算方式
    @Schema(description = "保养周期", example = "保养周期")
    @ExcelProperty("保养周期")
    private Long upkeepPeriod;


    @Schema(description = "是否临时保养")
    @ExcelProperty("是否临时保养")
    private Integer ifTmp;

    //模具寿命
    @Schema(description = "模具寿命")
    @ExcelProperty("模具寿命")
    private Integer totalUsageCount;

    //已用寿命
    @Schema(description = "已用寿命")
    @ExcelProperty("已用寿命")
    private Integer usedCount;

    @Schema(description = "上次保养日期")
    @ExcelProperty("上次保养日期")
    private LocalDateTime lastUpkeepTime;

    @Schema(description = "下次保养日期")
    @ExcelProperty("下次保养日期")
    //@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime nextUpkeepTime;


    @Schema(description = "剩余天数", requiredMode = Schema.RequiredMode.REQUIRED)
    @ExcelProperty("剩余天数")
    private Integer remaining;


    @Schema(description = "状态", example = "2")
    @ExcelProperty(value = "状态", converter = DictConvert.class)
    @DictFormat("mold_upkeep_tobe_status") // TODO 代码优化：建议设置到对应的 DictTypeConstants 枚举类中
    private Integer status;

    @Schema(description = "任务id", example = "27427")
    @ExcelProperty("任务id")
    private Long taskId;

    @Schema(description = "提醒标志位", requiredMode = Schema.RequiredMode.REQUIRED, example = "1423")
    @ExcelProperty("提醒标志位")
    private Integer remindF;

    @Schema(description = "保养项目主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "1423")
    @ExcelProperty("保养项目主键")
    private Long itemId;


    @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
    @ExcelProperty("创建时间")
    private LocalDateTime createTime;

    //预警颜色
    private String color;

}
